Add setting and command to show/hide cells in outline#974
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
juliasilge
left a comment
There was a problem hiding this comment.
This setting right now is only read when we start the app, so the experience is that the user changes the setting but doesn't observe the behavior change. I think we need to either:
- add a listener for config change for this setting, OR
- add a note to the setting description like "Restart to apply" or similar
Co-authored-by: Julia Silge <julia.silge@gmail.com>
In my testing in both VSCode and Positron, when I use the "Quarto: Toggle Code Cells in Outline" command the change in the outline is instantly reflected. Are you not experiencing that in your testing? Or do you mean if the user changes the setting manually we should notify them to restart? |
Yep, that's right. Right now, if the user changes the setting, nothing happens until the next time they close/open the app or reload the window. I think the best choice is to use It also would be worth re-examining the no-op edit hack and seeing if we can either:
|
|
@juliasilge I tried both the methods you mentioned and more, but was not able to get the outline to refresh without using the no-op edit hack (VSCode seems to have an outline cache that we can't bust without making an edit to the document?). I've pulled out the no-op edit hack into I tested and this method of refreshing the outline seems to work well. Kapture.2026-05-19.at.12.16.08.mp4@juliasilge what do you think? Too hacky and we should tell the user to refresh or make an edit themselves? It seems to work well, so I think I would lean towards using the hack. |
|
@vezwork I pushed 338c145 on top of your work that takes a different swing at the no-op edit hack, plus fixes a related cold-start bug that has been contributing to bad behavior in this area. We can revert that commit if we don't think this is a good way to go but I'd love to pitch you on this different approach! 😅 Part of the bad experience around the outline and why you were needing that no-op edit hack is that reloading the window (or opening VS Code with a previously-open
There are four main things to keep track of in my commit there:
There are some tradeoffs compared to what you had in this PR. Your no-op edit hack approach preserved outline expansion state natively; mine loses it on re-registration and we have to explicitly restore it with Take a look and see what you think! I'd love to get a better, less risky approach here. |
|
I was also able to add tests for this in dc5b7cb. |
Co-authored-by: Julia Silge <julia.silge@gmail.com>
|
@juliasilge I am completely sold on your pitch. Not only is your approach less hacky, it also feels nicer to use because the outline refreshes more immediately. I refactored the code a lil bit:
|
|
My one (maybe nitpick) concern is that if the user has multiple qmds open, only the first qmd they visit after changing their |
|
Overall I'm happy with where this PR is at now and would be down to merge if you are @juliasilge . |
|
Thanks for the tests btw! Did you have any trouble getting them working?? (edit: maybe tests work now because your approach is less hacky!?) |
juliasilge
left a comment
There was a problem hiding this comment.
Did you have any trouble getting them working??
Not really; I think the problem before was all the bad timing with onDocumentSymbol but once that was resolved in a better way, the tests could "just work".
Thank you for the nice improvements in 1c6bda3!
Fixes #647
Kapture.2026-05-08.at.12.51.44.mp4
symbols.showCodeCellsInOutlinesetting to theQuartoconfiguration,quarto.toggleCodeCellsInOutlinecommand to toggle that setting.Note: I attempted to add tests but for some reason in the tests the outline / document symbols refuse to change. I tried many things including waiting longer during the test after calling
quarto.toggleCodeCellsInOutline, programmatically getting document symbols withvscode.executeDocumentSymbolProvider, looking with my own eyes at the outline during the test. I'm not sure why it doesn't work in the test environment!